<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

    <meta name="author" content="kissdata">


    <meta name="subtitle" content="人生笔记">


    <meta name="description" content="南邮计算机学院2021毕业生王鹏的介绍，cs软件工程专业">


    <meta name="keywords" content="wangpeng 王鹏 南邮 南京">


<title>🆗 | Centos7 安装openSlide | 王鹏的小岛</title>



    <link rel="icon" href="/myIcon.ico">




    <!-- stylesheets list from _config.yml -->
    
    <link rel="stylesheet" href="/css/style.css">
    



    <!-- scripts list from _config.yml -->
    
    <script src="/js/script.js"></script>
    
    <script src="/js/tocbot.min.js"></script>
    



    
    
        <!-- MathJax配置，可通过单美元符号书写行内公式等 -->
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
    "HTML-CSS": {
        preferredFont: "TeX",
        availableFonts: ["STIX","TeX"],
        linebreaks: { automatic:true },
        EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)
    },
    tex2jax: {
        inlineMath: [ ["$", "$"], ["\\(","\\)"] ],
        processEscapes: true,
        ignoreClass: "tex2jax_ignore|dno",
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    TeX: {
        equationNumbers: { autoNumber: "AMS" },
        noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } },
        Macros: { href: "{}" }
    },
    messageStyle: "none"
    });
</script>
<!-- 给MathJax元素添加has-jax class -->
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>
<!-- 通过连接CDN加载MathJax的js代码 -->
<script type="text/javascript" async
        src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>


    


<meta name="generator" content="Hexo 7.0.0"></head>

<body>
    <script>
        // this function is used to check current theme before page loaded.
        (() => {
            const currentTheme = window.localStorage && window.localStorage.getItem('theme') || '';
            const isDark = currentTheme === 'dark';
            const pagebody = document.getElementsByTagName('body')[0]
            if (isDark) {
                pagebody.classList.add('dark-theme');
                // mobile
                document.getElementById("mobile-toggle-theme").innerText = "· Dark"
            } else {
                pagebody.classList.remove('dark-theme');
                // mobile
                document.getElementById("mobile-toggle-theme").innerText = "· Light"
            }
        })();
    </script>

    <div class="wrapper">
        <header>
    <nav class="navbar">
        <div class="container">
            <div class="navbar-header header-logo"><a href="/">侠之大者</a></div>
            <div class="menu navbar-right">
                
                    <a class="menu-item" href="/update/mystate">Career</a>
                
                    <a class="menu-item" href="/category">Legend</a>
                
                    <a class="menu-item" href="/about">Me</a>
                
                <input id="switch_default" type="checkbox" class="switch_default">
                <label for="switch_default" class="toggleBtn"></label>
            </div>
        </div>
    </nav>

    
    <nav class="navbar-mobile" id="nav-mobile">
        <div class="container">
            <div class="navbar-header">
                <div>
                    <a href="/">侠之大者</a><a id="mobile-toggle-theme">·&nbsp;Light</a>
                </div>
                <div class="menu-toggle" onclick="mobileBtn()">&#9776; Menu</div>
            </div>
            <div class="menu" id="mobile-menu">
                
                    <a class="menu-item" href="/update/mystate">Career</a>
                
                    <a class="menu-item" href="/category">Legend</a>
                
                    <a class="menu-item" href="/about">Me</a>
                
            </div>
        </div>
    </nav>

</header>
<script>
    var mobileBtn = function f() {
        var toggleMenu = document.getElementsByClassName("menu-toggle")[0];
        var mobileMenu = document.getElementById("mobile-menu");
        if(toggleMenu.classList.contains("active")){
           toggleMenu.classList.remove("active")
            mobileMenu.classList.remove("active")
        }else{
            toggleMenu.classList.add("active")
            mobileMenu.classList.add("active")
        }
    }
</script>
            <div class="main">
                <div class="container">
    
    
        <div class="post-toc">
    <div class="tocbot-list">
    </div>
    <div class="tocbot-list-menu">
        <a class="tocbot-toc-expand" onclick="expand_toc()">Expand all</a>
        <a onclick="go_top()">Back to top</a>
        <a onclick="go_bottom()">Go to bottom</a>
    </div>
</div>

<script>
    var tocbot_timer;
    var DEPTH_MAX = 6; // 为 6 时展开所有
    var tocbot_default_config = {
        tocSelector: '.tocbot-list',
        contentSelector: '.post-content',
        headingSelector: 'h1, h2, h3, h4, h5',
        orderedList: false,
        scrollSmooth: true,
        onClick: extend_click,
    };

    function extend_click() {
        clearTimeout(tocbot_timer);
        tocbot_timer = setTimeout(function() {
            tocbot.refresh(obj_merge(tocbot_default_config, {
                hasInnerContainers: true
            }));
        }, 420); // 这个值是由 tocbot 源码里定义的 scrollSmoothDuration 得来的
    }

    document.ready(function() {
        tocbot.init(obj_merge(tocbot_default_config, {
            collapseDepth: 1
        }));
    });

    function expand_toc() {
        var b = document.querySelector('.tocbot-toc-expand');
        var expanded = b.getAttribute('data-expanded');
        expanded ? b.removeAttribute('data-expanded') : b.setAttribute('data-expanded', true);
        tocbot.refresh(obj_merge(tocbot_default_config, {
            collapseDepth: expanded ? 1 : DEPTH_MAX
        }));
        b.innerText = expanded ? 'Expand all' : 'Collapse all';
    }

    function go_top() {
        window.scrollTo(0, 0);
    }

    function go_bottom() {
        window.scrollTo(0, document.body.scrollHeight);
    }

    function obj_merge(target, source) {
        for (var item in source) {
            if (source.hasOwnProperty(item)) {
                target[item] = source[item];
            }
        }
        return target;
    }
</script>
    

    
    <article class="post-wrap">
        <header class="post-header">
            <h1 class="post-title">🆗 | Centos7 安装openSlide</h1>
            
                <div class="post-meta">
                    
                        Author: <a itemprop="author" rel="author" href="/">kissdata</a>
                    

                    
                        <span class="post-time">
                        Date: <a href="#">Jul 27, 2022&nbsp;&nbsp;0:00</a>
                        </span>
                    
                    
                        <span class="post-category">
                    Category:
                            
                                <a href="/categories/Deploy/">Deploy</a>
                            
                        </span>
                    
                </div>
            
        </header>

        <div class="post-content">
            <p>openslide ，搭建提取医疗图像的环境。不直接编译安装openslide，利用基于它的开源<code>C库</code> libvips。</p>
<p>环境：Centos7 + libvips</p>
<figure class="highlight scala"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">  tool       version</span><br><span class="line"># -- -- -- | -- -- -- #</span><br><span class="line">· <span class="type">Go</span>          <span class="number">1.19</span></span><br><span class="line">· <span class="type">GCC</span>         <span class="number">11.2</span></span><br><span class="line">· libvips     <span class="number">8.3</span></span><br></pre></td></tr></table></figure>



<p>任务：尝试开发一种提取这种金字塔图像中所有小图像的程序。</p>
<p><img src="/../image/knowledge_libvips/logic4extract.png"></p>
<h2 id="一、更新-Gcc"><a href="#一、更新-Gcc" class="headerlink" title="一、更新 Gcc"></a>一、更新 Gcc</h2><p>⚠ 必须更新。因为centOS7默认的4.8.5不能识别c99语法（ libvips源码好几处是在for参数列表 int 定义变量 ）。</p>
<p>不要下载源码编译，那些在虚机里至少要四五个小时才能编译完。选择gcc11，参考 📗 <a target="_blank" rel="noopener" href="https://ae85.gitee.io/2022/10-2/knowledge_gcc/">CentOS升级GCC</a></p>
<h2 id="二、安装openslide"><a href="#二、安装openslide" class="headerlink" title="二、安装openslide"></a>二、安装openslide</h2><p>WSI类的图像结构如下（来自推特 @mauroccm）</p>
<p><img src="/../image/knowledge_libvips/structureWSI.jpg"></p>
<p>【方法一】直接 yum 安装 </p>
<p>直接安装 devel版（不过大部分源没有），去了make过程。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">openslide is <span class="keyword">in</span> epel</span></span><br><span class="line">RUN yum install -y \</span><br><span class="line">    https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm</span><br><span class="line">RUN yum install -y openslide-devel</span><br></pre></td></tr></table></figure>

<p>【方法二】源程序 make 安装</p>
<p>注意：缺少xx程序，要安装xx的devel，不是安装xx本身。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">wget https://github.com/openslide/openslide/releases/download/v3.4.1/openslide-3.4.1.tar.gz</span><br><span class="line">tar -zxf openslide-3*</span><br><span class="line">cd openslide-3.4.1</span><br><span class="line">yum install libjpeg-turbo-devel.x86_64</span><br><span class="line">yum install openjpeg-devel  # 安装的是1.5版，最新版需要源码编译</span><br><span class="line">yum install openjpeg-devel  # 安装的是2.3版，最新版需要源码编译</span><br><span class="line">yum install zlib-devel libtiff-devel libxml2-devel</span><br><span class="line">yum install glib2-devel</span><br><span class="line">yum install cairo-devel gdk-pixbuf2-devel</span><br><span class="line"></span><br><span class="line">make &amp; make install</span><br></pre></td></tr></table></figure>

<p>会提醒</p>
<blockquote>
<p>Libraries have been installed in:<br>   &#x2F;usr&#x2F;local&#x2F;lib</p>
</blockquote>
<p>刷新缓存  <code>ldconfig</code></p>
<h2 id="三、安装libvips"><a href="#三、安装libvips" class="headerlink" title="三、安装libvips"></a>三、安装libvips</h2><h3 id="3-1-直接centos安装"><a href="#3-1-直接centos安装" class="headerlink" title="3.1 直接centos安装"></a>3.1 直接centos安装</h3><p><strong>1 先装基本依赖</strong>，根据自己需求可扩大。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">yum install -y libjpeg-devel libpng-devel libtiff-devel \</span><br><span class="line">   glib2-devel \</span><br><span class="line">   orc-devel \</span><br><span class="line">   expat-devel \</span><br><span class="line">   zlib-devel \ </span><br><span class="line">   libexif-devel \</span><br><span class="line">   libgsf-devel \</span><br><span class="line">   libgif-devel</span><br></pre></td></tr></table></figure>

<p><strong>2 动态库链接配置</strong>，和opencv.pc遇到的问题语言，不弄会提示找不到 <code>vips.pc</code> </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH</span><br><span class="line">export LD_LIBRARY_PATH=/usr/local/lib</span><br></pre></td></tr></table></figure>

<blockquote>
<p><code>pkg-config</code> 就是用于返回一个包的头文件和动态库的编译选项信息。pkg-config根据<code>PKG_CONFIG_PATH</code> 找到目录下面的 <code>.pc</code> 文件(描述了一个包的详细信息) 默认是 &#x2F;usr&#x2F;lib&#x2F;pkgconfig。</p>
</blockquote>
<p>🚫 不要更新 <code>GLIBC</code> 程序。🚫</p>
<p>如果出现 <code>lib64/libm.so.6: version &#39;GLIBC_2.29&#39; not found</code> 果断重装。CentOS7 默认 2.17版本 <code>GLIBC</code> <a target="_blank" rel="noopener" href="https://ftp.gnu.org/gnu/glibc/">官网</a>，可以用查看命令 <code>strings /lib64/libc.so.6 |grep GLIBC_</code></p>
<h3 id="3-2-docker安装"><a href="#3-2-docker安装" class="headerlink" title="3.2 docker安装"></a>3.2 docker安装</h3><p>参考github <a target="_blank" rel="noopener" href="https://github.com/jcupitt/docker-builds/tree/master/libvips-centos7">docker-builds&#x2F;libvips-centos7</a></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker pull centos:centos7</span><br><span class="line">docker build -t libvips-centos7 .</span><br></pre></td></tr></table></figure>

<h2 id="四、常用-vips命令"><a href="#四、常用-vips命令" class="headerlink" title="四、常用 vips命令"></a>四、常用 vips命令</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">vipsheader -a name.svs  # 获取文件信息</span><br><span class="line">vips dzsave /xxx/name.svs[level=1] /xxx/output_dir/ --suffix=.png --depth=one</span><br><span class="line">vips openslideload /xxx/CMU-1.svs /xxx/test.dz --autocrop --vips-progress</span><br></pre></td></tr></table></figure>


        </div>

        
            <section class="post-copyright">
                
                
                
                
                     <p class="copyright-item">
                         <span>Slogan:</span>
                         <span>人生三大错觉：我躲得过去，我能反杀，是不是<strong>喜欢我?</strong></span>
                     </p>
                

            </section>
        
        <section class="post-tags">
            <div>
            </div>
            <div>
                <a href="javascript:window.history.back();">back</a>
                <span>· </span>
                <a href="/">home</a>
            </div>
        </section>
        <section class="post-nav">
            
                <a class="prev" rel="prev" href="/2022/08-15/review_conf/">配置文件json的使用</a>
            
            
            <a class="next" rel="next" href="/2022/03-8/ability_se/">我的专业所学</a>
            
        </section>


    </article>
</div>

            </div>
            <footer id="footer" class="footer">
    <div class="copyright">
        <span>187-9597-5517 &nbsp; 王鹏 @ <a href="https://cs.njupt.edu.cn/" target="_blank">njupt</a</span>
    </div>
</footer>

    </div>
</body>

</html>